<%@page import="study.top.mydb.items.ReviewItem"%>
<%@page import="study.top.mydb.Review"%>
<%@page import="study.top.jsp.MultipartBox.FileInfo"%>
<%@page import="java.util.ArrayList"%>
<%@page import="study.top.common.DateTime"%>
<%@page import="study.top.mydb.items.BoardItem"%>
<%@page import="study.top.mydb.Board"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page session="true" %>
<%@ include file="dbcon.jsp" %>
<%@ include file="topcategory.jsp" %>
<%
	db.connect();
	int seq = web.getInt("seq");
	

	if(seq<0) {
		web.goPage(null, "파라미터가 없습니다.");
		db.disconnect();
		return;
	}

	Review review = new Review();
	ReviewItem rv_item = review.read(seq);
	db.disconnect();

	if(rv_item==null) {
		web.goPage(null, "게시물 데이터를 불러오는데 실패했습니다.");		
		return;
	}

%>

<!DOCTYPE html>
<html lang="ko">
<%@include file="topHead.jsp"%>

<body>
	
	<div class="top-tab top-hidden-xs">
		<%@include file="tab.jsp"%>
	</div>
			<!-- .modal -->
		<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<!-- .modal-dialog -->
			<form class="modal-dialog" name="delete_form" method="post" action="uBrdMyReviewdelete_ok.jsp" role="form">
				<input type="hidden" name="seq" value="<%=seq%>" />
				<!-- .modal-content -->
				<div class="modal-content">
					<!-- 제목 -->
					<div class="modal-header">
						<!-- 닫기버튼 -->
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							&times;
						</button>
						<h4 class="modal-title" id="myModalLabel">게시물 삭제</h4>
					</div>
					<!-- 내용 -->
					<div class="modal-body">
						<h4>정말 게시물을 삭제하시겠습니까?</h4>
						
					</div>
					<!-- 하단 -->
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">
							취소
						</button>
						<button type="submit" class="btn btn-primary">
							삭제
						</button>
					</div>
				</div>
				<!-- /.modal-content -->
			</form>
			<!-- /.modal-dialog -->
		</div>
		<!-- /.modal -->
		<div class="container" style="width: 70%">
		
			<div class="page-header">
				<h3>나의 리뷰</h3>
			</div>
	
			<form class="form-horizontal" role="form" action="uBrdMyReviewedit.jsp" method="post">
				<input type="hidden" name="seq" value="<%=seq%>" />
				
				<fieldset>			
				
				
				<div class="table-responsive">
			<table class="table table-striped table-hover ">
				<thead>
					<tr>
						<th>
							<h4><%=rv_item.getTitle()%></h4>
							<div class="pull-right">
								<%=DateTime.getInstance().getDateTimeString(rv_item.getReg_date())%>
							</div>
						</th>
								
					</tr>
				</thead>
				
				
				<tbody>
					<tr class="text-center">
						
						<td class="text-left">
							<p>
								글쓴이 : 
								<a class="text-left" href=""><%=rv_item.getMemberID() %></a>
								
							</p>
						</td>
					
					</tr>
					
					<tr class="text-center">
						
						<td class="text-left">
						
							<% 
	ArrayList<FileInfo> imageList = rv_item.getImageList();
	if (imageList != null) {
		for (int i = 0; i < imageList.size(); i++) {
			FileInfo info = imageList.get(i);
			String src = "download.jsp?" + info.toString("utf-8");
%>
							<p class="form-control-static">
							<a href="<%=src%>" data-lightbox="roadtrip" title="<%=rv_item.getTitle()%>"><img src="<%=src%> class="img-thumbnail img-resonsive" /></a></p>
<%
		}
	}
%>
							<p class="form-control-static"><%=rv_item.getContent()%></p>
						</td>
					</tr>
				
				</tbody>
			</table>
		</div>
				
						
					
					<!-- 입력양식 -->
					<div class="form-group">
						<div class="col-md-12">

						</div>
					</div>
					<!--// 입력양식 -->
					
					<!-- 입력양식 -->
					<div class="form-group">
						<div class="col-md-12">
						
								<div class="pull-right">
								<%
								// 로그인 시 자신의 게시물에만 보이도록 분기
									if(mem_seq == rv_item.getMember_seq() || mem_seq == 1){
								%>							
									<button type="submit" class="btn top-btn-custom ">수정</button>
								<a data-toggle="modal" href="#myModal" class="btn top-btn-custom">삭제</a>
								<a href="uBrdMyReviewlistMe.jsp" class="btn top-btn-custom">나의 리뷰</a>
								<%
									}
								%>					
								<button id="back" type="button" class="btn btn-default">목록가기</button>
								</div>
							</div>
						</div>
			
					<!--// 입력양식 -->
					
					
					
				</fieldset>
			</form>
		</div>
		<div class="top-hidden-xs">
			<%@ include file="topBottom.jsp" %>
		</div>
			
				<!-- Javascript -->
				
				<script src="assets/js/lightbox-2.6.min.js"></script>
				<link rel="stylesheet" type="text/css" href="assets/css/lightbox.css"/>
				<script type="text/javascript">
					$(function(){
						$('#back').click(function(){
							history.back();
						});
						
					});
					
				</script>
				
	</body>
</html>